package truedano.truedanostock;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class MyDB extends SQLiteOpenHelper{
	private static final int VERSION = 1;//Data Base Version
	public static String STOCK_NUMBER="number";
	public static String STOCK_NAME="name";
	public static String STOCK_PRICE="stock_price";
	public static String AVERAGE_DIV="average_div";
	public static String CHEAP_PRICE="cheap_price";
	public static String NORMAL_PRICE="normal_price";
	public static String HIGH_PRICE="high_price";
	public static String FORECAST_DIV="forecast_div";
	public static String UPDATE_TIME="update_time";
	public static String MEMO="memo";
	
	public MyDB(Context context, String name, CursorFactory factory, int version) {
		super(context, name, factory, version);
		// TODO Auto-generated constructor stub
	}
	
	public MyDB(Context context,String name){
		this(context, name, null, VERSION);
	}
	
	public MyDB(Context context, String name, int version) {  
	    this(context, name, null, version);  
	}
	
	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		String DATABASE_CREATE_TABLE =
			     "create table newMemorandum("
			       + "_ID INTEGER PRIMARY KEY  AUTOINCREMENT  NOT NULL,"
			       + "date VARCHAR,"
			       + "note VARCHAR,"
			       + "pw VARCHAR,"
			       + "reminder INT,"
			       + "type VARCHAR,"
			       + "number VARCHAR,"
			       + "name VARCHAR,"
			       + "stock_price VARCHAR,"
			       + "average_div VARCHAR,"
			       + "cheap_price VARCHAR,"
			       + "normal_price VARCHAR,"
			       + "high_price VARCHAR,"
			       + "forecast_div VARCHAR,"
			       + "update_time VARCHAR,"
			       + "memo VARCHAR"
			       + ")";
		db.execSQL(DATABASE_CREATE_TABLE);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub
		db.execSQL("DROP TABLE IF EXISTS newMemorandum"); //Delete old Table
		onCreate(db);
	}
	
	@Override
	public void onOpen(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		super.onOpen(db);
	}
	
	@Override
	public synchronized void close() {
		// TODO Auto-generated method stub
		super.close();
	}
}
